#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
ll a[N], pre[N], suf[N], sum[N], n, k;//pre k的前缀,suf k的后缀, sum是总和的前缀
void solve()
{
    cin >> n >> k;
    memset(pre, -0x3f, sizeof pre);
    memset(suf, -0x3f, sizeof suf);
    for(int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + a[i];//从一开始方便计算

    for(int i = k; i <= n; i++) pre[i] = max(pre[i - 1], sum[i] - sum[i - k]);//与上一个区间比一下
    for(int i = n - k + 1; i >= 1; i--) suf[i] = max(suf[i + 1], sum[i - 1 + k] - sum[i - 1]);

    ll ans = pre[k] + suf[k + 1]; //k为最左端的满足条件的区间
    for(int i = k; i <= n - k; i++) ans = max(ans, pre[i]+suf[i + 1]);
    cout << ans << '\n';
}

int main()
{
    close();
    int T; cin >> T;
    while (T--) solve();
    return 0;
}